﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MyStore.Products;
using NHibernate;

namespace MyStore.SqlDataAccess.Repositories
{
    public class ProductRepository : NHRepository, IProductRepository
    {
        public ProductRepository(ISession session) : base(session) { }

        #region IProductRepository 成员

        public IList<Product> GetNewProduct(int index, int size)
        {
            return session.CreateCriteria<Product>()
                    .AddOrder(NHibernate.Criterion.Order.Desc("OnlineTime"))
                    .SetFirstResult(index * size)
                    .SetMaxResults(size)
                    .List<Product>();
        }

        #endregion
    }
}
